#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui/QMainWindow>
#include "registerdef.h"

class QLabel;
class QLineEdit;
class QCheckBox;
class QTableView;
class QMdiArea;
class QMdiSubWindow;
class PIDwidget;
class RegisterGraph;
class RegisterModel;
class RegisterRefreshModel;
class TargetComms;
class LogFileDecoder;

namespace Ui
{
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:
    void on_actionEraseFlash_triggered();
    void on_bRemove_clicked();
    void on_iInterval_editingFinished();
    void on_actionDump_triggered();
    void on_actionRefresh_triggered();
    void on_actionConnect_triggered();
    void on_actionConvertLog_triggered();
    void on_actionNew_Graph_Window_triggered();
    void on_cbLogStatus_toggled(bool checked);

    void targetConnected(bool success, QString port);
    void registerListFetched(bool success);
    void registerUpdated(RegisterDef reg);
    void dumpFinished();
    void eraseFlashFinished();
    void targetLost();

    void closeGraphWindow(QObject *obj);

    void decodeComplete();

private:
    void updateRtcRegisters();

    TargetComms *thread;
    LogFileDecoder *decodethread;
    Ui::MainWindow *ui;

    QList<RegisterGraph*> graphWindows;
    QList<RegisterDef> *m_regList;

    QLabel* ui_lblPort;
    QCheckBox* ui_cbConnected;
    QTableView* ui_tbRegisters;
    QTableView* ui_tbRefresh;
    QLineEdit* ui_iInterval;
    QMdiArea* ui_mdiArea;
    QCheckBox* ui_cbLogStatus;
    QMdiSubWindow* ui_refreshWindow;
    PIDwidget* ui_pidWidget;
    RegisterModel *regModel;
    RegisterRefreshModel *refreshModel;

    int autoLogStore;
    bool harnessLogStore;
    bool targetFound;
};

#endif // MAINWINDOW_H
